package com.example.bysj_sb.service;

import com.example.bysj_sb.dao.TitleDao;
import com.example.bysj_sb.domain.ProfTitle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("profTitleService")
//@Transactional注解：可以用在方法上和类上，用在类上代表这个类的所有公共非静态方法都将启用事务功能。
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation. REQUIRED)
public class ProfTitleService {
    @Autowired
    private TitleDao profTitleDao;

    //添加
    public Boolean add(ProfTitle profTitle){
        return profTitleDao.add(profTitle);
    }
    //根据id查找
    public ProfTitle find(int id){
        ProfTitle profTitle = profTitleDao.find(id);
        return profTitle;
    }
    //查找全部
    public List<ProfTitle> findAll(){
        List<ProfTitle> profTitles = profTitleDao.findAll();
        return profTitles;
    }
    //修改
    public Boolean update(ProfTitle profTitle){
        return profTitleDao.update(profTitle);
    }
    //删除
    public Boolean delete(int id){
        return profTitleDao.delete(id);
    }
}
